#!/usr/bin/php
<?php
#alp-cleanup: Cleanup old backups that weren't removed correctly
#(C) Copyright 2010-2011 Nicholas Paun. All Rights Reserved.

$conf = parse_ini_file("/etc/alpine-backup/".$argv[1],TRUE);
$item = $argv[2];

if($argc != 3)
 {
  echo("Invalid number of arguments.\nSyntax: ".$argv[0]."<server> <item>\n"); 
  die(2);
 }

if (!isset($conf["$item"]))
 {
  echo("* Cleanup Failure ($item): Invalid item.\n");
  die(1);
 }

extract($conf["$item"]);
echo("* Cleaning up old backups ($item on ".$argv[1].").\n");

$old = date("Y-m-d",strtotime($delete_after));
passthru("find $dest/ -maxdepth 1 -type d -daystart ! -newerct $old -exec rm -rf {} \;");
?>
